/*
 *
 *  ------------------------------------------------------------------
 *  Copyright © 2017 Hangzhou DtDream Technology Co.,Lt d. All rights reserved.
 *  ------------------------------------------------------------------
 *        Product:  EMR
 *    Module Name: NEZHA
 *   Date Created: 17-10-23 下午4:22
 *    Description:
 *  ------------------------------------------------------------------
 *  Modification History
 *  DATE            Name           Description
 *  ------------------------------------------------------------------
 *  2017-10-23      NEZHA EMR
 *  ------------------------------------------------------------------
 * /
 */

package org.xukai.remoting.sdk.web;

import java.net.MalformedURLException;
import java.net.URL;
import java.sql.SQLException;
import org.xukai.remoting.sdk.web.api.RestAPIClient;

/**
 * Created by moriarty on 17-2-23.
 */
public class SQLClientManager {

    RestAPIClient restClient;

    /**
     * NeZha SQL Service Entrance.
     *
     * @param nezhaUrl NeZha http address
     */
    public SQLClientManager(String nezhaUrl) {
        try {
            this.restClient = new RestAPIClient(new URL(nezhaUrl));
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("Invalid NeZha URL", e);
        }
    }

    public SQLClient newSQLClient(AccessKey accessKey, String database) throws SQLException {
        return new SQLClientImpl(accessKey, database, this);
    }
}
